home *** CD-ROM | disk | FTP | other *** search
/ Personal Computer World 2009 February / PCWFEB09.iso / Software / Resources / Burning & Media / GB-PVR 1.2.13 / GBPVR10213.msi / Cabs.w1.cab / ManualRecord2.aspx.cs614 < prev    next >
Text File  |  2007-12-14  |  7KB  |  194 lines

  1. using System;
  2. using System.Web;
  3. using System.Web.UI;
  4. using GBPVR.Public;
  5. using GBPVRSchedule;
  6.  
  7. namespace gbweb
  8. {
  9.     public partial class ManualRecord2 : Page
  10.     {
  11.         private Settings guideParams;
  12.  
  13.         protected void Page_Load(object sender, EventArgs e)
  14.         {
  15.             getTheme();
  16.  
  17.             if (!IsPostBack)
  18.             {
  19.                 //Load the settings from the config file
  20.                 guideParams = Global.Settings;
  21.  
  22.                 //Fill the drop down list of channels
  23.                 Global.FillChannelList(listChannels);
  24.  
  25.                 //Set the default name for the recording...display class will provide "Manual Recording"
  26.                 //if this feild remains null
  27.                 pgmName.Text = null;
  28.  
  29.                 //Set the default recording Quality
  30.                 quality.SelectedValue = guideParams.recordingQuality;
  31.  
  32.                 //Default the start date to today
  33.                 startDate.SelectedDate = DateTime.Now;
  34.  
  35.                 //Default the start time to now
  36.                 startTime.SelectedTime = DateTime.Now;
  37.  
  38.                 //Default the stop time to 1 hour from the start time
  39.                 endTime.SelectedTime = DateTime.Now.AddHours(1);
  40.  
  41.                 //Ensure the error message box is not displaying
  42.                 ERROR_MESSAGE.Visible = false;
  43.             }
  44.  
  45.         }
  46.         protected void LinkButton1_Click(object sender, EventArgs e)
  47.         {
  48.             bool scheduleReturn = true;
  49.  
  50.             //Create a Programme
  51.             Programme dummyPgm = new Programme();
  52.  
  53.             //Set the channel that is to be recorded
  54.             dummyPgm.setChannelOID(Convert.ToInt32(listChannels.SelectedValue));
  55.  
  56.             //Set the start time for for programme to record
  57.             string sDate = startDate.SelectedDate.ToShortDateString();
  58.             string sTime = startTime.SelectedTime.ToShortTimeString();
  59.             DateTime fullStartDate = Convert.ToDateTime(sDate + " " + sTime);
  60.             dummyPgm.setStartTime(fullStartDate);
  61.  
  62.             //Set the end time for the programme to record
  63.             string eDate = startDate.SelectedDate.ToShortDateString();
  64.             string eTime = endTime.SelectedTime.ToShortTimeString();
  65.             DateTime fullEndDate = Convert.ToDateTime(eDate + " " + eTime);
  66.  
  67.             //Update the end date if the recording spans two different dates
  68.             if (fullEndDate.Hour < fullStartDate.Hour)
  69.             {
  70.                 fullEndDate = fullEndDate.AddDays(1);
  71.             }
  72.             dummyPgm.setEndTime(fullEndDate);
  73.  
  74.             if (pgmName.Text.Length > 0)
  75.             {
  76.                 dummyPgm.setTitle(pgmName.Text);
  77.             }
  78.  
  79.             Schedule.Quality quality = 0;
  80.             int prePad = Convert.ToInt32(prePadding.Text);
  81.             int postPad = Convert.ToInt32(postPadding.Text);
  82.             switch (Request.Params["quality"].ToLower())
  83.             {
  84.                 case "high":
  85.                     quality = Schedule.Quality.High;
  86.                     break;
  87.  
  88.                 case "medium":
  89.                     quality = Schedule.Quality.Medium;
  90.                     break;
  91.  
  92.                 case "low":
  93.                     quality = Schedule.Quality.Low;
  94.                     break;
  95.  
  96.                 case "custom1":
  97.                     quality = Schedule.Quality.Custom1;
  98.                     break;
  99.  
  100.                 case "custom2":
  101.                     quality = Schedule.Quality.Custom2;
  102.                     break;
  103.             }
  104.  
  105.             if (radioDay.SelectedValue == "once")
  106.             {
  107.                 // schedule one-off recording
  108.                 Schedule myschedule = Global.Schedule;
  109.                 scheduleReturn = myschedule.ScheduleOnce(dummyPgm, quality, prePad, postPad);
  110.             }
  111.             else
  112.             {
  113.                 //Schedule Season Recordings
  114.                 //Set the max number of recordings to keep for the show
  115.                 int keepnumRecordings = ReoccuringRecordingExtras.KEEP_ALL_FILES;
  116.                 if (keepRecordings.Text.ToString() != null)
  117.                 {
  118.                     try
  119.                     {
  120.                         keepnumRecordings = Convert.ToInt32(keepRecordings.Text);
  121.                     }
  122.                     catch
  123.                     {
  124.                         keepnumRecordings = ReoccuringRecordingExtras.KEEP_ALL_FILES;
  125.                     }
  126.                 }
  127.                 else
  128.                 {
  129.                     keepnumRecordings = ReoccuringRecordingExtras.KEEP_ALL_FILES;
  130.                 }
  131.  
  132.                 Schedule myschedule = Global.Schedule;
  133.  
  134.                 // schedule manual recording for every day of the week
  135.                 if (radioDay.SelectedValue == "everyDay")
  136.                 {
  137.                     scheduleReturn = myschedule.ScheduleThisTime(dummyPgm, quality, Schedule.DayType.SheduleAnyDay, keepnumRecordings, Schedule.RecType.Daily, prePad, postPad);
  138.                 }
  139.                 // schedule manual recording for this day on each week
  140.                 else if (radioDay.SelectedValue == "everyWeek")
  141.                 {
  142.                     scheduleReturn = myschedule.ScheduleThisTime(dummyPgm, quality, Schedule.DayType.SheduleThisDay, keepnumRecordings, Schedule.RecType.Weekly, prePad, postPad);
  143.                 }
  144.                 // schedule manual recording for weekdays
  145.                 else if (radioDay.SelectedValue == "weekDays")
  146.                 {
  147.                     scheduleReturn = myschedule.ScheduleThisTime(dummyPgm, quality, Schedule.DayType.SheduleThisDay, keepnumRecordings, Schedule.RecType.WeekDays, prePad, postPad);
  148.                 }
  149.                 // schedule manual recording for weekends
  150.                 else if (radioDay.SelectedValue == "weekEnd")
  151.                 {
  152.                     scheduleReturn = myschedule.ScheduleThisTime(dummyPgm, quality, Schedule.DayType.SheduleThisDay, keepnumRecordings, Schedule.RecType.WeekEnds, prePad, postPad);
  153.                 }
  154.             }
  155.  
  156.             //Display error message if recording does not schedule
  157.             if (scheduleReturn)
  158.             {
  159.                 // close popup details window
  160.                 ClientScript.RegisterStartupScript(typeof(String), "startupScript", "<script language=JavaScript>reloadAndClose();</script>", false);
  161.             }
  162.             else
  163.             {
  164.                 RecordMessage.Text = "Recording Failed!";
  165.                 ERROR_MESSAGE.Visible = true;
  166.             }
  167.         }
  168.  
  169.         private void getTheme()
  170.         {
  171.             string theme = Convert.ToString(Session["theme"]);
  172.  
  173.             if (theme != null && theme != "")
  174.             {
  175.                 return;
  176.             }
  177.             else
  178.             {
  179.                 HttpCookie cookie = Request.Cookies["theme"];
  180.                 if (cookie != null && cookie.Value.Length > 0)
  181.                 {
  182.                     theme = cookie.Value;
  183.                 }
  184.                 else
  185.                 {
  186.                     theme = "Default";
  187.                 }
  188.                 Session["theme"] = "themes/" + theme;
  189.                 return;
  190.             }
  191.         }
  192. }
  193. }
  194.